﻿using System;
using System.Collections.Generic;
using DatabaseStorageDemo.Storage;
using TallComponents.Web.Storage;

namespace DatabaseStorageDemo
{
   public partial class _Default : System.Web.UI.Page
   {
      protected override void OnLoad( EventArgs e )
      {
         base.OnLoad( e );

         if ( !string.IsNullOrEmpty( Request.Params[ "doc" ] ) )
         {
            pdfViewer.StorageKey = Request.Params[ "doc" ];
         }
      }

      protected IEnumerable<DatabaseDocumentInfo> Documents
      {
         get { return ( ( DatabaseStorageProvider )PdfStorage.Provider ).ListDocuments(); }
      }

      protected void OnAddClicked( object sender, EventArgs e )
      {
         if ( Upload1.PostedFile != null && Upload1.PostedFile.ContentLength > 0 )
         {
            PdfStorage.Provider.StoreFile( Upload1.PostedFile );
         }
      }
   }
}
